import React from 'react'
import ReactDOM from 'react-dom/client'
import '@/index.scss'
import { RouterProvider } from 'react-router-dom'
import { Provider } from 'react-redux'
import router from '@/router'
import store from '@/store'
import 'normalize.css'
// i18n
import i18n from 'i18next';
import { initReactI18next } from 'react-i18next';
import enTranslations from './translations/en/global.json';
import esTranslations from './translations/es/global.json';
import zhTranslations from './translations/zh/global.json';

// 初始化 i18next
i18n.use(initReactI18next).init({
  resources: {
    en: { global: enTranslations },  // "global" 是命名空间
    es: { global: esTranslations },
    zh: { global: zhTranslations }
  },
  lng: 'en', // 默认语言
  fallbackLng: 'en',
  interpolation: {
    escapeValue: false // 防止 XSS 攻击
  }
});

const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement)
root.render(
	<React.StrictMode>
		<Provider store={store}>
		<RouterProvider router={router} />
		</Provider>
	</React.StrictMode>
)
